package it.uniroma2.structure;

import java.util.Vector;

public class Reply extends Actions{
	private final String defaultName = "replyOutput";
	private static int index = 1;
	private Parameter result;
	private Vector<LinkServiceNode> inLinksService;
	
	public Reply(){
		super.name = this.defaultName + Reply.index;
		Reply.index++;
		this.result = new Parameter("result", "string");
		this.inLinksService = new Vector<LinkServiceNode>();
	}
	
	public Reply(String name){
		super.name = name;
		this.inLinksService = new Vector<LinkServiceNode>();
		this.result = new Parameter("result", "string");
	}
	
	public String toBPEL(){
		return "<" + replyTag + " " + this.toString() + "/>\n";
	}
	
	public Parameter getParameterResult(){
		return this.result;
	}

	@Override
	public String toString() {
		return "name=\"" + super.name + "\" " +
				"partnerLink=\"" + super.partnerLink.getName() + "\" " +
						"portType=\"" + super.portType + "\" " +
								"operation=\"" + super.operation + "\" " +
										"variable=\"" + super.variable.getName() + "\"";
	}

	public void addInLink(LinkServiceNode newLinkNode) {
		this.inLinksService.addElement(newLinkNode);
		
	}
	
	public void removeInLink(LinkServiceNode inLink) {
		this.inLinksService.remove(inLink);
		
	}
}
